﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;
using School.Entities;
using School.Common;

namespace School.Organization
{   
    public static class Stage
    {
        private static SchoolEntities db = new SchoolEntities();
       
        public static ORG_Stage Single(long id)
        {
            var stages = from x in db.ORG_Stage where x.Id == id select x;

            if (stages.Count() > 0)
                return stages.First();
            else
                return null;
        }

        public static void Add(ORG_Stage stage)
        {
            db.AddToORG_Stage(stage);
            db.SaveChanges();
        }

        public static void Update(ORG_Stage stage)
        {
            ORG_Stage s = Single(stage.Id);
            s.Name = stage.Name;
            s.Description = stage.Description;
            s.Code = stage.Code;
            s.Certificate_Id = stage.Certificate_Id;
            db.SaveChanges();
        }
    }
}
